import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);

import request from '../utils/request';

export default new Vuex.Store({
  state: {
    userInfo: {},
  },
  getters: {
    userInfo: (state) => state.userInfo,
  },
  mutations: {
    SET_USER_INFO(state, data) {
      state.userInfo = data;
    },
  },
  actions: {
    GetUserInfo({ commit }, data) {
      return request.get('/user/info').then((res) => {
        commit('SET_USER_INFO', res.data);
        return res;
      });
    },
  },
  modules: {}
});
